package me.zhengjie.modules.stock.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

/**
 * @website https://el-admin.vip
 * @description /
 * @author yyj
 * @date 2021-10-14
 **/
@Entity
@Data
@Table(name="stock")
public class Stock extends BaseEntity implements Serializable {
    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "ID")
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "stock_name",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "股票名称")
    private String stockName;

    @Column(name = "stock_code",nullable = false)
    @NotNull
    @ApiModelProperty(value = "股票编号")
    private Integer stockCode;

    @Column(name = "stock_type",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "股票类型")
    private String stockType;

    @Column(name = "buy_price",nullable = false)
    @NotNull
    @ApiModelProperty(value = "买入价格")
    private BigDecimal buyPrice;

    @Column(name = "sell_price",nullable = false)
    @ApiModelProperty(value = "卖出价格")
    private BigDecimal sellPrice;

    @Column(name = "buy_time",nullable = false)
    @NotNull
    @ApiModelProperty(value = "买入时间")
    private Timestamp buyTime;

    @Column(name = "sell_time",nullable = false)
    @ApiModelProperty(value = "卖出时间")
    private Timestamp sellTime;

    @Column(name = "hold_num",nullable = false)
    @NotNull
    @ApiModelProperty(value = "持有数量")
    private Integer holdNum;

//    @Column(name = "hold_time",nullable = false)
//    @NotNull
//    @ApiModelProperty(value = "持有天数")
//    private Integer holdTime;

    @Column(name = "earn_money",nullable = false)
    @ApiModelProperty(value = "赚取差价")
    private BigDecimal earnMoney;

    @Column(name = "share_mood")
    @ApiModelProperty(value = "分享心得")
    private String shareMood;

    @Column(name = "pic_name")
    @ApiModelProperty(value = "图片名称")
    private String picName;

    @Column(name = "pic_path")
    @ApiModelProperty(value = "图片路径")
    private String picPath;

    @Column(name = "del_flag")
    @ApiModelProperty(value = "删除标记")
    private Integer delFlag;

    public void copy(Stock source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}